driver: skip -Bsymbolic on unregisterised targets
authorDebian Haskell Group <pkg-haskell-maintainers@lists.alioth.debian.org>
Tue, 24 Mar 2020 01:50:31 +0000 (01:50 +0000)
committerSandro Tosi <morph@debian.org>
Tue, 24 Mar 2020 01:50:31 +0000 (01:50 +0000)
commit20334264647dd1be145e42a38793f8b6ca597270
tree55490372b252ff65d5ee417da7f595f97c15b7c2
parente642fbb32cafc48cdcfd982f947ac727630dd381
driver: skip -Bsymbolic on unregisterised targets

Trac #15338 is yet another example where -Bsymbolic breaks
semantics of a C program: global variable duplication happens
and unsafePerformIO creates two stdout copies.

When -Bsymbolic is not used both C compiler and linker agree
on how global variables are handled. In case of sh4 it consists
on a few assertions:

1. global variable is exported from shared library
2. code is referred to this variable via GOT-like mechanism to allow
   interposition
3. global variable is present .bss section on an executable
   (as an R_*_COPY relocation: symbol contents is copied at executable
   startup time)
4. and symbol in executable interposes symbol in shared library.

This way both code in shared library and code in executable refer
to a copy of global variable in .bss section of an executable.

Unfortunately -Bsymbolic option breaks assumption [2.] and generates
direct references to the symbol. This causes mismatch between
values seen from executable and values seen from shared library code.

This change disables '-Bsymbolic' for unregisterised targets.

Gbp-Pq: Name bsymbolic-only-for-registerised.patch
compiler/main/SysTools.hs